<?php
	if(!defined('BASEPATH'))
		exit('No direct script access allowed');

	class m_notifications extends CI_Model
	{
		function __construct()
    	{
    	    // Call the Model constructor
    	    parent::__construct();
    	}
    	
    	function get_user_id($userEmail)
    	{
			$this->load->database();
			$this->db->select('userId')->from('tblUser')->where('userEmail', $userEmail);
			$query = $this->db->get();
			return $query;
    	}
		
    	function get_notifications($userId)
    	{
			$this->load->database();
			$this->db->select('*')->from('tblNotifications')->where('userId', $userId);
			$query = $this->db->get();
			return $query;
    	}

    	function insert_notification($userId, $date, $occurance, $message)
    	{
			$this->load->database();
			$this->db->insert('tblNotifications', array('userId' => $userId, 'message' => $message, 'nextSendDate' => $date));
		}
		
		function delete_notification($notificationID)
    	{
			$this->load->database();
			$this->db->delete('tblNotifications', array('notificationID' => $notificationID)); 
		}
	}
?>
